package com.yycx.module.weixin.provider.service.impl;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.base.service.impl.BaseServiceImpl;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.mybatis.query.CriteriaSave;
import com.yycx.module.weixin.client.entity.SysWechat;
import com.yycx.module.weixin.provider.mapper.SysWechatMapper;
import com.yycx.module.weixin.provider.service.SysWechatService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 接口实现类
 *
 * @author flyme
 * @date 2022-03-01
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SysWechatServiceImpl extends BaseServiceImpl<SysWechatMapper, SysWechat> implements SysWechatService {

    @Override
    public ResultBody beforeAdd(CriteriaSave cs, SysWechat wechat, EntityMap extra) {
        return ResultBody.ok();
    }


    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public ResultBody beforePageList(CriteriaQuery<SysWechat> cq, SysWechat wechat, EntityMap requestMap) {
        cq.like(SysWechat.class, "weChatName");
        return ResultBody.ok();
    }

    @Override
    public SysWechat getByAppId(String appId) {
        CriteriaQuery<SysWechat> cq = new CriteriaQuery(SysWechat.class);
        cq.lambda().eq(true, SysWechat::getAppId, appId);
        return getOne(cq, false);
    }
}
